1. Field of the Invention
The present invention relates to an image processing method and an image processing apparatus for detecting a linear object such as a linear scar, a hair and thread waste (hereinafter referred to collectively as “the linear object”) in the field of the gray-scale image data processing by the computer.
2. Description of the Prior Art
A conventional image processing method for detecting a linear defect is available in which images are picked up sequentially by scanning a line camera in the direction orthogonal to the arrangement of the image pickup elements, and a line of images obtained each time are processed. According to this method, a position with a different density is detected by binarizing a line of images, or the sum of densities is taken for each line so that the density sum for a line is compared to the density sum for the preceding and following lines. In this way, it is determined whether each line contains a linear defect or not.
On the other hand, the present applicant has recently developed an image processing method, as disclosed in Japanese Unexamined Patent Publication No. 2002-230562, in which the angle data (edge codes) indicating the edge direction of edge pixels contained in a gray-scale image are acquired, and a linear contour line (edges) is detected with high accuracy by the image processing using the edge codes. In this method, a histogram indicating the degree of an edge pixel corresponding to the value of each edge code is produced, and an edge pixel for an angle corresponding to each peak on the histogram is assigned a label unique to the particular peak. In the label image generated by the labeling process, a mass of successive edge images having the same label is verified to correspond to a line segment, and a unique label is assigned to each mass. In this way, various feature amounts are calculated and the line segments are integrated. After that, the process of specifying a line segment meeting the extraction conditions is executed.
In particular, the part of the specification of the aforementioned publication associated with FIG. 13 discloses a method of extracting a set of parallel line segments as a technique for specifying a line segment meeting the extraction conditions. Further, the same part of the same specification indicates that a linear scar or the like object having a very small width formed on the package can be extracted by setting a very small distance between the line segments to be extracted.
In the conventional method described first above in which a defect is detected by binarizing images acquired by a line camera or comparing the density sums for each line, the prerequisite is that the density of the background portion other than the defect is uniform in density and the density of the defect portion is considerably different from that of the background portion. A defect is difficult to detect, therefore, for an image low in contrast or having a background of uneven density due to a foul or a pattern.
According to the method described in the cited patent publication, in contrast, the detection is possible even in the case where the contrast of the image is decreased or the density variation of the background is increased. In this conventional method, however, a mass of a succession of images having the same edge code are required to be basically detected. Therefore, only rectilinear contour lines can be detected, and it is difficult to detect curved linear objects such as hairs and thread waste. It is also difficult to detect a finely uneven linear object such as a crack since the edge code is frequently changed at the uneven portion.
According to the method described in the cited patent publication, even in the case where the edge of a linear object can be extracted only partly in an image of low contrast, the portions not extracted can be complemented by the process of integrating the line segment. In this integrating process, however, it is necessary to confirm for each extracted line segment whether it can be integrated or not, using the feature amounts of each line segment. This increases the burden of the control operation, and the method is difficult to employ in such an application as a high-speed defect inspection which is conducted by sequentially picking up images of products conveyed on the conveyor.